package me.zk.practice1.list;

/**
 * @Author: zhang kai
 * @Date: 2022/01/11
 * @Description:
 */
public class Solution5 {
    public static void main(String[] args) {
        merge(new int[]{1,2,4},3,new int[]{2,5,6},3);
    }
    // 请按你的实际需求修改参数
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        //
        int s[] = new int[m+n];
        int l1= 0;
        int l2 = 0;
        int i =0;
        while(l1 < m || l2 < n) {
            if(nums1[l1] < nums2[l2]) {
                s[i] = nums1[l1];
                l1 = l1==m-1 ? l1 : l1+1;
            } else {
                s[i] = nums2[l2];
                l2 = l2==n-1 ? l2 : l2+1;
            }
            if (i++ >m+n) {
                break;
            }
        }
        nums1 = s;
    }
}
